import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.enableCors()
  app.useStaticAssets('uploads',{
    prefix: '/uploads'
  })
  const options = new DocumentBuilder()
    .setTitle('全栈之巅 - 后台管理API')
    .setDescription('最帅的坏兔子')
    .setVersion('1.0')
    .build()
  const document = SwaggerModule.createDocument(app, options)
  SwaggerModule.setup('api-docs', app, document)
  const PORT = process.env.ADMIN_PORT || 3001
  await app.listen(PORT);
  console.log(`http://localhost:${PORT}`)
  console.log(`http://localhost:${PORT}/api-docs`)
}
bootstrap();
